package com.tledu.schedulingInfo.controller;

import com.tledu.common.annotation.Log;
import com.tledu.common.core.controller.BaseController;
import com.tledu.common.core.domain.AjaxResult;
import com.tledu.common.core.page.TableDataInfo;
import com.tledu.common.enums.BusinessType;
import com.tledu.schedulingDuty.domain.SchedulingDuty;
import com.tledu.schedulingDuty.domain.vo.SelectListDutyVo;
import com.tledu.schedulingDuty.service.ISchedulingDutyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 值班列表Controller
 * 
 * @author ruoyi
 * @date 2024-09-04
 */
@RestController
@RequestMapping("/scheduling/duty")
public class SchedulingDutyController extends BaseController
{
    @Autowired
    private ISchedulingDutyService schedulingDutyService;

    /**
     * 查询值班列表列表
     */
    @PreAuthorize("@ss.hasPermi('scheduling:duty:list')")
    @GetMapping("/list")
    public TableDataInfo list(SchedulingDuty schedulingDuty)
    {
        startPage();
        List<SelectListDutyVo> list = schedulingDutyService.selectSchedulingDutyList(schedulingDuty);
        return getDataTable(list);
    }

    /**
     * 导出值班列表列表
     */
    // @PreAuthorize("@ss.hasPermi('scheduling:duty:export')")
    // @Log(title = "值班列表", businessType = BusinessType.EXPORT)
    // @PostMapping("/export")
    // public void export(HttpServletResponse response, SchedulingDuty schedulingDuty)
    // {
    //     List<SelectListDutyVo> list = schedulingDutyService.selectSchedulingDutyList(schedulingDuty);
    //     ExcelUtil<SchedulingDuty> util = new ExcelUtil<SchedulingDuty>(SchedulingDuty.class);
    //     util.exportExcel(response, list, "值班列表数据");
    // }

    /**
     * 获取值班列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('scheduling:duty:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(schedulingDutyService.selectSchedulingDutyById(id));
    }

    /**
     * 新增值班列表
     */
    @PreAuthorize("@ss.hasPermi('scheduling:duty:add')")
    @Log(title = "值班列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SchedulingDuty schedulingDuty)
    {
        return toAjax(schedulingDutyService.insertSchedulingDuty(schedulingDuty));
    }

    /**
     * 修改值班列表
     */
    @PreAuthorize("@ss.hasPermi('scheduling:duty:edit')")
    @Log(title = "值班列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SchedulingDuty schedulingDuty)
    {
        return toAjax(schedulingDutyService.updateSchedulingDuty(schedulingDuty));
    }

    /**
     * 删除值班列表
     */
    @PreAuthorize("@ss.hasPermi('scheduling:duty:remove')")
    @Log(title = "值班列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(schedulingDutyService.deleteSchedulingDutyByIds(ids));
    }
}
